function [data_out, sigma2] = WiSiL_Channel_Awgn( data_in, Eab, snr )
%WISIL_CHANNEL_AWGN Additive White Gaussian Noise channel
%
%  [ DATA_OUT, SIGMA2 ] = WiSiL_Channel_Awgn( DATA_IN, EB, SNR ) 
%    Adds white Gaussian noise to the input signal in DATA_IN , which is an
%    input matrix with complex elements. Each row corresponds to a
%    different antenna.
%    The noise variance depends on the Eb/N0 in dB, given in SNR, and on
%    the given average bit energy EB.
%    The noisy signal is output in DATA_OUT, the noise variance in SIGMA2.
%    

%  History:
%  ??, ???
%    created
%  Andre Noll Barreto, 21.03.11
%    code cleanup
%

% AWGN channel
sigma2 = Eab/(10^(snr/10));
sigma = sqrt(sigma2);

% complex noise (projection to I and Q components) for QPSK, X-QAM
w = randn(size(data_in));

% adjust mean and variance
z1 = (sigma/sqrt(2))*w;

w = randn(size(data_in));

% adjust mean and variance
z2 = (sigma/sqrt(2))*w;

% channel output   
data_out = (data_in + z1 + 1i*z2);





